//
//  ChaKanQuanBuViewController.m
//  JuBoCRM
//
//  Created by iMac on 2024/2/22.
//  Copyright © 2024 iningKe. All rights reserved.
//

#import "ChaKanQuanBuViewController.h"
#import "ChaKanQuanBuCollectionViewCell.h"
@interface ChaKanQuanBuViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
@property (weak, nonatomic) IBOutlet UICollectionView *mainCollectionView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topSpace;

@end

@implementation ChaKanQuanBuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.customNavBar.title = @"查看全部";
    
    
    _topSpace.constant = NavaBarHeight;

    
    if (@available(iOS 11.0, *)) {
        self.mainCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    
    [_mainCollectionView registerNib:[UINib nibWithNibName:@"ChaKanQuanBuCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"ChaKanQuanBuCollectionViewCell"];
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return _dataSource.count;
}
//创建cell
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    ChaKanQuanBuCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ChaKanQuanBuCollectionViewCell" forIndexPath:indexPath];
    NSDictionary *dataDic = _dataSource[indexPath.row];
    [cell.itemImage sd_setImageWithURL:WebImagePath(GetHandleString(dataDic, @"img")) placeholderImage:HeadImagePlaceholder];
    cell.nameLabel.text = GetHandleString(dataDic, @"realname");
    return cell;
}

//设置item的大小
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake((ScreenWidth-16)/5, 84);
}
//设置垂直间距,默认的垂直和水平间距都是10
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
    return 0;
}
//设置水平间距
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
    return 0;
}

//四周的边距
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    return UIEdgeInsetsMake(0, 8, 0, 8);
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
   
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
